package com.prs.crm.dao.oa.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.oa.PictureNewsCollectTypeDao;
import com.prs.crm.domain.oa.NewsCollectType;
import com.prs.crm.domain.oa.PictureNewsCollectType;

public class PictureNewsCollectTypeDaoImpl extends BaseDaoImpl<PictureNewsCollectType> implements PictureNewsCollectTypeDao{

	@Override
	public PictureNewsCollectType getTypeByName(String name) {
		Criteria criteria = this.getSession().createCriteria(PictureNewsCollectType.class);
		criteria.add(Restrictions.eq("name", name));
		List<PictureNewsCollectType> list = criteria.list();
		if(list.size()!=0){
			return list.get(0);
		}else{
			return null;
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<PictureNewsCollectType> getAll() {
		Criteria criteria = this.getSession().createCriteria(PictureNewsCollectType.class);
		return criteria.list();
	}

}
